from pydantic import BaseModel
from pydantic.generics import GenericModel
from typing import Generic, TypeVar


T = TypeVar('T')


class Link(GenericModel, Generic[T]):
    ul: T
    dl: T

    def __round__(self, n=1):
        link = Link()
        link.ul = round(self.ul, 1)
        link.dl = round(self.dl, 1)
        return link

    def __mul__(self, other):
        link = Link()
        link.ul = self.ul
        link.dl = self.dl
        link.ul *= other
        link.dl *= other
        return link

    def __imul__(self, other: T):
        self.ul *= other
        self.dl *= other
        return self

    def __truediv__(self, other: T):
        self.ul /= other
        self.dl /= other
        return self

    def __floordiv__(self, other: T):
        self.ul //= other
        self.dl //= other
        return self

